import { ApiProperty, IntersectionType, PartialType } from '@nestjs/swagger'
import {
  IsNumber,
  IsOptional,
  IsString,
} from 'class-validator'
import { PagerDto } from '~/common/dto/pager.dto'

export class UserDataDto {
  @ApiProperty({ description: '用户ID' })
  @IsNumber()
  userId: number

  @ApiProperty({ description: '设备ID' })
  @IsString()
  uid: string

  @ApiProperty({ description: '数据类型' })
  @IsNumber()
  type: number

  @ApiProperty({ description: '时间戳' })
  @IsNumber()
  ts: number

  @ApiProperty({ description: '告警规则ID' })
  ruleId: number

  @ApiProperty({ description: '告警ID' })
  alarmId: number

  @ApiProperty({ description: '数据' })
  data: any
}

export class UserDataQueryDto extends IntersectionType(PagerDto, PartialType(UserDataDto)) {
  @ApiProperty({ description: '序列号', required: false })
  @IsOptional()
  @IsString()
  sn?: string

  @ApiProperty({ description: 'MAC地址', required: false })
  @IsOptional()
  @IsString()
  mac?: string

  @ApiProperty({ description: '设备名称', required: false })
  @IsOptional()
  @IsString()
  name?: string

  @ApiProperty({ description: '设备类型', required: false })
  @IsOptional()
  @IsNumber()
  type?: number

  @ApiProperty({ description: '时间' })
  @IsOptional()
  time?: string[]

  @ApiProperty({ description: '部门ID', required: false })
  @IsOptional()
  @IsNumber()
  deptId?: number
}
